package com.wyg.service;

import javax.servlet.http.Cookie;

import com.wyg.bean.User;

public class LoginBiz {
	
	public boolean validateUser(User user){
		if("admin".equals(user.getUserName())&&"123".equals(user.getUserPassword())){
			return true;
		}
		return false;
	}
	public User getUserByCookie(Cookie[] cks) {
		User user = new User();
		Cookie[] cookies = cks;
		Cookie cookie = null;
		String name = "";
		String value = "";
		if (cookies != null) {
			for (int i = 0; i < cookies.length; i++) {
				cookie = cookies[i];
				name = cookie.getName();
				value = cookie.getValue();
				if ("userName".equals(name)) {
					user.setUserName(value);
				} else if ("userPassword".equals(name)) {
					user.setUserPassword(value);
				}
			}
		}
		return user;
	}

}
